package com.heima.admin.v1.controller;

import com.heima.admin.service.AdSensitiveService;
import com.heima.common.dtos.PageResult;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.admin.dtos.SensitiveDto;
import com.heima.model.media.dtos.SensitiveResponseDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Fuqiang
 * @since :2023-04-07
 */

import com.heima.common.dtos.ResponseResult;
import com.heima.model.admin.dtos.SensitiveDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/sensitive")
public class SensitiveController {

    @Autowired
    AdSensitiveService sensitiveService;

    /**
     * 保存敏感词
     *
     * @param dto
     * @return
     */
    @PostMapping("/save")
    public ResponseResult saveSensitive(@RequestBody SensitiveDto dto) {
        this.sensitiveService.saveSensitive(dto);
        return ResponseResult.ok();
    }

    /**
     * 查询列表
     *
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public PageResult<SensitiveResponseDTO> findList(@RequestBody SensitiveDto dto) {
        return sensitiveService.findList(dto);
    }

    /**
     * 修改敏感词
     *
     * @param dto
     * @return
     */
    @PutMapping("/update")
    public ResponseResult updateSensitive(@RequestBody SensitiveDto dto) {
        this.sensitiveService.updateSensitive(dto);

        return ResponseResult.ok();
    }

    /**
     * 删除敏感词
     *
     * @param id
     * @return
     */
    @DeleteMapping("/del/{id}")
    public ResponseResult deleteSensitive(@PathVariable("id") Integer id) {

        this.sensitiveService.deleteSensitive(id);
        return ResponseResult.ok();
    }
}



